﻿namespace zyn_hy_login
{
    using System;
    using System.Data;
    using System.Web;
    using System.Web.SessionState;

    public class mkCheck
    {
        private HttpResponse httpR;
        private string strProNums;

        public mkCheck(HttpSessionState nowSession, HttpResponse hR, string strMknum)
        {
            if (nowSession["aspuid"] == null)
            {
                hR.Redirect("/z8/alert.aspx?z8_alert=login");
            }
            else
            {
                this.httpR = hR;
                this.strProNums = "";
                if (nowSession["mkCheck" + strMknum] != null)
                {
                    this.strProNums = nowSession["mkCheck" + strMknum].ToString();
                }
                else
                {
                    string text = nowSession["aspuid"].ToString();
                    string text2 = "select distinct pro.num";
                    string text3 = text2 + " from z8_pro pro,role_pro rp,user_role ur ";
                    foreach (DataRow row in DBCommon.getDataBySql((text3 + "where pro.id=rp.id2 and rp.id=ur.role_id and ur.user_id=" + text + " and pro.id3=" + strMknum) + " and rp.zt='q' and sign='pro' ").Tables[0].Rows)
                    {
                        if (this.strProNums == "")
                        {
                            this.strProNums = row["num"].ToString();
                            continue;
                        }
                        this.strProNums = this.strProNums + "," + row["num"].ToString();
                    }
                    nowSession.Add("mkCheck" + strMknum, this.strProNums);
                }
            }
        }

        public void CheckPopedom(string proNum)
        {
            if (this.strProNums.IndexOf(proNum) == -1)
            {
                this.httpR.Redirect("/z8/alert.aspx?z8_alert=nomk");
            }
        }
    }
}

